import typeOfUtils from "../../../utils/type-of-utils";
import RenderUtils from "../RenderUtils";
import {RenderTypeItem} from "../ConfigType";

const colorPicker: RenderTypeItem = {
  name: 'colorPicker',
  /**
   *
   * @param createElement
   * @param vm
   * @param formItem
   * @return {VNode[]}
   */
  render(createElement, vm, formItem) {
    let predefine = formItem.props.predefine || []
    if (typeOfUtils.isEmpty(predefine) && typeOfUtils.isFunction(formItem.props.setPredefine)) {
      predefine = formItem.props.setPredefine() || []
    }
    const config = RenderUtils.getConfig(vm, formItem, {
      props: {
        predefine
      },
    }, this)
    return [
      createElement(`el-color-picker`, config)
    ]
  }
}

export default colorPicker
